package data 
{
	import flash.utils.Dictionary;
	/**
	 * ...
	 * @author Roy
	 */
	public class GCBuildingData 
	{
		// Building types
		public static const BUILDING_TYPE_STORAGE:uint = 0;
		public static const BUILDING_TYPE_HARVEST:uint = 1;
		public static const BUILDING_TYPE_SPECIAL:uint = 2;
		
		// Harvest buildings
		public static const BUILDING_FARM:uint = 0;
		public static const BUILDING_LUMBER_MILL:uint = 1;
		public static const BUILDING_WAREHOUSE:uint = 2;
		public static const BUILDING_IRON_MINE:uint = 3;
		public static const BUILDING_SILVER_MINE:uint = 4;
		public static const BUILDING_COPPER_MINE:uint = 5;
		public static const BUILDING_COAL_MINE:uint = 6;
		public static const BUILDING_WOOL_SWEAT_SHOP:uint = 7;
		public static const BUILDING_COTTON_SWEAT_SHOP:uint = 8;
		public static const BUILDING_SILK_SWEAT_SHOP:uint = 9;
		public static const BUILDING_OIL_FIELD:uint = 10;
		public static const BUILDING_SPICE_STALL:uint = 11;
		public static const BUILDING_SALT_STALL:uint = 12;
		
		public static const NUM_BUILDINGS:uint = 13;
		
		// HACK, for database this indicates a task of idle for crew
		public static const BUILDING_NONE:uint = 1000;
		
		// The capacity of a normal warehouse
		public static const WAREHOUSE_CAPACITY:uint = 200;
		
		public static var _information:Dictionary;
		
		public static function initialize():void
		{
			_information = new Dictionary();
			var resourceCost:Dictionary;
			var producedResourceId:uint;
			var goldCost:uint;
			var type:uint;
			var name:String;
			var desc:String;
			
			/*
			 * Initialize all information about buildings in the section of code
			 * below.
			 */
			
			// Mines: Iron, silver, copper, coal
			
			name = "Iron Mine";
			resourceCost = new Dictionary();
			goldCost = 200;
			type = BUILDING_TYPE_HARVEST;
			desc = "Yields a hard metal for all your hard problems";
			producedResourceId = GCItemData.ITEM_IRON;
			_information[BUILDING_IRON_MINE] = new GCBuildingDataStruct(name, goldCost, resourceCost, type, desc, null, producedResourceId);
			
			name = "Silver Mine";
			resourceCost = new Dictionary();
			goldCost = 500;
			type = BUILDING_TYPE_HARVEST;
			desc = "Yields a beautiful, shiny metal for jewelry and intricate devices";
			producedResourceId = GCItemData.ITEM_SILVER;
			_information[BUILDING_SILVER_MINE] = new GCBuildingDataStruct(name, goldCost, resourceCost, type, desc, null, producedResourceId);
			
			name = "Copper Mine";
			resourceCost = new Dictionary();
			goldCost = 300;
			type = BUILDING_TYPE_HARVEST;
			desc = "Produces a malleable metal for construction";
			producedResourceId = GCItemData.ITEM_COPPER;
			_information[BUILDING_COPPER_MINE] = new GCBuildingDataStruct(name, goldCost, resourceCost, type, desc, null, producedResourceId);
			
			name = "Coal Mine";
			resourceCost = new Dictionary();
			goldCost = 600;
			type = BUILDING_TYPE_HARVEST;
			desc = "Produces a malleable metal for construction";
			producedResourceId = GCItemData.ITEM_COAL;
			_information[BUILDING_COAL_MINE] = new GCBuildingDataStruct(name, goldCost, resourceCost, type, desc, null, producedResourceId);
			
			
			// Sweat shops: Wool, cotton, silk
			
			name = "Wool Sweat Shop";
			resourceCost = new Dictionary();
			goldCost = 600;
			type = BUILDING_TYPE_HARVEST;
			desc = "Produces a warm fuzzy cloth to keep you warm at night";
			producedResourceId = GCItemData.ITEM_WOOL;
			_information[BUILDING_WOOL_SWEAT_SHOP] = new GCBuildingDataStruct(name, goldCost, resourceCost, type, desc, null, producedResourceId);
			
			name = "Cotton Sweat Shop";
			resourceCost = new Dictionary();
			goldCost = 300;
			type = BUILDING_TYPE_HARVEST;
			desc = "Produces a cheap and comfy textile quite efficiently";
			producedResourceId = GCItemData.ITEM_COTTON;
			_information[BUILDING_COTTON_SWEAT_SHOP] = new GCBuildingDataStruct(name, goldCost, resourceCost, type, desc, null, producedResourceId);
			
			name = "Silk Sweat Shop";
			resourceCost = new Dictionary();
			goldCost = 800;
			type = BUILDING_TYPE_HARVEST;
			desc = "Makes the finest silks";
			producedResourceId = GCItemData.ITEM_SILK;
			_information[BUILDING_SILK_SWEAT_SHOP] = new GCBuildingDataStruct(name, goldCost, resourceCost, type, desc, null, producedResourceId);
			
			
			// Other
			
			name = "Oil Field";
			resourceCost = new Dictionary();
			goldCost = 1200;
			type = BUILDING_TYPE_HARVEST;
			desc = "Produces oil to power your motors";
			producedResourceId = GCItemData.ITEM_OIL;
			_information[BUILDING_OIL_FIELD] = new GCBuildingDataStruct(name, goldCost, resourceCost, type, desc, null, producedResourceId);
			
			name = "Farm";
			resourceCost = new Dictionary();
			goldCost = 200;
			type = BUILDING_TYPE_HARVEST;
			desc = "Produces the freshest ingredients for your crew's meals!";
			producedResourceId = GCItemData.ITEM_FOOD;
			_information[BUILDING_FARM] = new GCBuildingDataStruct(name, goldCost, resourceCost, type, desc, null, producedResourceId);
			
			name = "Timber Mill";
			resourceCost = new Dictionary();
			goldCost = 150;
			type = BUILDING_TYPE_HARVEST;
			desc = "TIIIMBERRRR!!";
			producedResourceId = GCItemData.ITEM_LUMBER;
			_information[BUILDING_LUMBER_MILL] = new GCBuildingDataStruct(name, goldCost, resourceCost, type, desc, null, producedResourceId);
			
			name = "Spice Stall";
			resourceCost = new Dictionary();
			goldCost = 1000;
			type = BUILDING_TYPE_HARVEST;
			desc = "Spicy!";
			producedResourceId = GCItemData.ITEM_SPICES;
			_information[BUILDING_SPICE_STALL] = new GCBuildingDataStruct(name, goldCost, resourceCost, type, desc, null, producedResourceId);
			
			name = "Salt Stall";
			resourceCost = new Dictionary();
			goldCost = 1000;
			type = BUILDING_TYPE_HARVEST;
			desc = "Get your daily dose of sodium here!";
			producedResourceId = GCItemData.ITEM_SALT;
			_information[BUILDING_SALT_STALL] = new GCBuildingDataStruct(name, goldCost, resourceCost, type, desc, null, producedResourceId);
			
			// TODO: How much does this store?
			name = "Warehouse";
			resourceCost = new Dictionary();
			goldCost = 100;
			type = BUILDING_TYPE_STORAGE;
			desc = "Stores your goods while you are away"
			_information[BUILDING_WAREHOUSE] = new GCBuildingDataStruct(name, goldCost, resourceCost, type, desc);

		}
		
		public static function getNameFromId(id:int):String
		{
			return (_information[id] as GCBuildingDataStruct)._name;
		}
		
		public static function getResourceFromId(id:int):uint
		{
			return (_information[id] as GCBuildingDataStruct)._resourceGatheredId;
		}
		
		public static function getGoldCostFromId(id:int):uint
		{
			return (_information[id] as GCBuildingDataStruct)._goldCost;
		}
		
		public static function getResourceCostFromId(id:int):Dictionary
		{
			return (_information[id] as GCBuildingDataStruct)._resourceCost;
		}
		
		public static function getBuildingTypeFromId(id:int):uint
		{
			return (_information[id] as GCBuildingDataStruct)._type;
		}
		
		/**
		 * Gets back a text description of a building.
		 * 
		 * @param	id
		 * @return
		 */
		public static function getDescriptionFromId(id:int):String
		{
			return (_information[id] as GCBuildingDataStruct)._description;
		}
	}

}